package com.class5.springboot.frame.web.result;

import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("serial")
public class ResultSuccess extends ResultData {
    public ResultSuccess() {
        this.content = new HashMap<>();
        setSuccess(true);
    }
    public ResultSuccess(Object content) {
        setSuccess(true);
        this.content = content;
    }
    //内容包装
    private Object content;

    public Object getContent() {
        return content;
    }

    public void setContent(Object content) {
        this.content = content;
    }
    /**
     * 添加返回值
     * @param key
     * @param val
     * @return
     */
    @SuppressWarnings("unchecked")
    public ResultSuccess add(String key, Object val){
        if(content == null){
            content = new HashMap<>();
        }
        ((Map<String, Object>)content).put(key, val);
        return this;
    }

    @Override
    public String toString() {
        return "ResultSuccess [success=true,content=" + content + "]";
    }
}